package com.syf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.syf.mail.QQMail;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syf.domain.store.BsFeedback;
import com.syf.mapper.BsFeedbackMapper;
import com.syf.service.BsFeedbackService;
import org.springframework.transaction.annotation.Transactional;

/**
*
*
*@author syf
*@create 2022-02-07 19:09
*/
@Service
public class BsFeedbackServiceImpl extends ServiceImpl<BsFeedbackMapper, BsFeedback> implements BsFeedbackService{

    @Autowired
    private QQMail qqMail;


    /**
     * 用户反馈列表
     * @return
     */
    @Override
    public Page<BsFeedback> findByPage(BsFeedback bsFeedback) {
        Page<BsFeedback> page = new Page<>(bsFeedback.getCurrent(),bsFeedback.getSize());
        String problemType = bsFeedback.getProblemType();
        Integer manageStatus = bsFeedback.getManageStatus();
        Integer feedbackType = bsFeedback.getFeedbackType();
        String softwareCode = bsFeedback.getSoftwareCode();
        LambdaQueryWrapper<BsFeedback> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.isNotEmpty(problemType),BsFeedback::getProblemType,problemType)
                .eq(manageStatus != null, BsFeedback::getManageStatus,manageStatus)
                .eq(feedbackType != null, BsFeedback::getFeedbackType,feedbackType)
                .eq(StringUtils.isNotBlank(softwareCode), BsFeedback::getSoftwareCode,softwareCode)
                .orderByDesc(BsFeedback::getCreateTime);
        Page<BsFeedback> feedbackPage = page(page, wrapper);
        return feedbackPage;
    }

   /* *//**
     * 处理用户反馈
     *
     * @param bsFeedback
     * @return
     *//*
    @Override
    @Transactional
    public boolean handleFeedback(BsFeedback bsFeedback) {
        qqMail.sendMessage(bsFeedback.getRelationType(),bsFeedback.getMsg(),bsFeedback.getSubject());
        bsFeedback.setManageStatus(1);
        return updateById(bsFeedback);
    }*/
}
